<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/layoutnew.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/iconfont/iconfont.css"/>
    <style>
        html,body{
            background:url(../../images/bac.png) no-repeat;
            height: 100%;
        }

    </style>
</head>
<body ondblclick="closeFrame()">

<div class="aui-bar-nav-new" style="z-index: 99;position: fixed;top: 0">
    <div class="aui-pull-left" onclick="closeFrame();">
        <span class="icon iconfont icon-back">返回</span>
    </div>
    <span>平均年龄人数</span>

    <div class="aui-pull-right"style="color: transparent ">
        <span class="icon iconfont icon-back">占位</span>
    </div>
</div>

<div style="width: 100%;height: 99%;margin:0 auto;padding:3%;overflow: auto;">
    <div class="echartstwo">
        <div id="sixthPlot1" class="echartsfour">

        </div>
    </div>

    <!--表格-->
    <table id="message-content" border="0" class="table_rylb conytb">

    </table>
</div>


<script id="message-content-template" type="text/x-dot-template">
    <!--列表-->

        <table >
            <thead class="blue-bg">
            <tr>
                <th style="width: 9%;">
                    &nbsp
                </th>
                <th style="width: 9%;">
                    20岁及以下
                </th>
                <th style="width: 9%;">
                    21~25岁
                </th>
                <th style="width: 9%;">
                    26~30岁
                </th>
                <th style="width: 9%;">
                    31~35岁
                </th>
                <th style="width: 9%;">
                    36~40岁
                </th>
                <th style="width: 9%;">
                    41~45岁
                </th>
                <th style="width: 9%;">
                    46~50岁
                </th>
                <th style="width: 9%;">
                    51~55岁
                </th>
                <th style="width: 9%;">
                    56~59岁
                </th>
                <th style="width: 9%;">
                    60岁及以上
                </th>
            </tr>
            </thead>

            <tr class="white-bg">
                <td>{{=it[10]}}</td>
                <td onclick="clickopenpeo('21','20','20岁以下','{{=it[0]}}')">{{=it[0]}} </td>

                <td onclick="clickopenpeo('22','20','21-25岁','{{=it[1]}}')">{{=it[1]}}</td>

                <td onclick="clickopenpeo('23','20','25-30岁','{{=it[2]}}')">{{=it[2]}}</td>

                <td  onclick="clickopenpeo('24','20','31-35岁','{{=it[3]}}')">{{=it[3]}}</td>

                <td  onclick="clickopenpeo('25','20','36-40岁','{{=it[4]}}')">{{=it[4]}}</td>
                <td  onclick="clickopenpeo('26','20','41-45岁','{{=it[5]}}')">{{=it[5]}}</td>
                <td  onclick="clickopenpeo('27','20','46-50岁','{{=it[6]}}')">{{=it[6]}}</td>
                <td onclick="clickopenpeo('28','20','51-55岁','{{=it[7]}}')">{{=it[7]}}</td>
                <td onclick="clickopenpeo('29','20','56-59岁','{{=it[8]}}')">{{=it[8]}}</td>
                <td onclick="clickopenpeo('30','20','60岁及以上','{{=it[2]}}')">{{=it[9]}}</td>
            </tr>

        </table>



</script>


</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/scriptabxz.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/leek-common.js"></script>
<script type="text/javascript" src="../../script/echarts.min.js"></script>
<script type="text/javascript">

    var place_code
    apiready = function(){
        var   pageParam = api.pageParam.item.containe_arr;
        place_code = api.pageParam.item.place_code

        showMiddleTopZhongyangChart(pageParam)


        pageParam.push('总人数')

        var interText = doT.template($("#message-content-template").text());
        $("#message-content").html(interText(pageParam));


        api.addEventListener({
            name: 'cleanarr'
        }, function (ret, err) {
            cleanarr()
        })
    };

    function showMiddleTopZhongyangChart(data) {
        middle_top_zhongyang_chart = echarts.init(document.getElementById('sixthPlot1'))

        middle_top_zhongyang_chart.showLoading({text: '正在努力的读取数据中...'})

        consoledebug.log('showMiddleTopZhongyangChart data is : ' + JSON.stringify(data))


      var count_array = data

        var setOption = {
            tooltip: {
                trigger : 'item'
            },
            color : [ '#FF8635' ],
            grid: {
                top:"23%",
                left: "5%",
                right: "8%",
                bottom: "15%"
            },
            xAxis: {
                type: 'category',
                name : '岁',
                data: ['20及以下', '21~25', '26~30', '31~35', '36~40', '41~45', '46~50', '51~55', '56~59', '60及以上'],

                axisLabel: {
                    show : true,
                    interval : 0,//横轴信息全部显示
                    textStyle: {
                        fontSize:1
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#0087ED',
                        width: 1 //这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false
                }
            },
            yAxis: {
                type: 'value',
                name: '人',
                axisLabel: {
                    show: false,
                    formatter: '{value}'
                },
                axisLine: {
                    lineStyle: {
                        color: '#0087ED',
                        width: 1 //这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    show: false
                }
            },
            series: [{
                name: '人数',
                type: 'bar',
                smooth : false,
                data: count_array,
                showAllSymbol: true,
                barWidth : 14,

                label: {
                    normal: {
                        position:'top',
                        show : true,
                        //  formatter: "{b}\n{c}人",
                        //    formatter: "{c}",
                        formatter:function(params){
                            return dealNum1(params.value);//+"人"
                        },
                        textStyle: {
                            fontSize:6
                        }
                        // padding: [5, 10, 5, 10],
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '8',
                            fontWeight: 'bold'
                        }
                    }
                }
            }]
        };


        middle_top_zhongyang_chart.setOption(setOption)

        middle_top_zhongyang_chart.hideLoading()
    }


    var rossidlist = []

    var colsidlist = []

    var peosqllist = []
    var sqlthree = null


    var colrowidnumber

    var number


    var sqlwhereone


    function clickopenpeo(colsid, rowsid, name, val, ID) {

        colrowidnumber = 0
        number = 0

        rossidlist = rowsid.split(",");

        colsidlist = colsid.split(",");

        colrowidnumber = parseInt(rossidlist.length)*parseInt(colsidlist.length)

        var sql_arr = []
        if (val != 0) {
            for (i = 0; i < rossidlist.length; i++) {
                for (a = 0; a < colsidlist.length; a++) {
                    selectSql(converFcrySql(colsidlist[a], rossidlist[i]), function (ret, err) {
                        var sql = ret.data[0].DRILLSQL;
                        var newsql = sql.replace(/\"/g, "'");
                        var sqlone = newsql.substring(newsql.lastIndexOf("@FIELDS@") + 9, newsql.lastIndexOf("AND"));

                        var pjsqlone = sqlone.substring(0, sqlone.lastIndexOf("AND") + 3);
                        //   pjsqltwo = newsql.substring(newsql.lastIndexOf(")") + 1, newsql.lastIndexOf(","));

                        sqlwhereone = newsql.substring(newsql.lastIndexOf("@FIELDS@") + 9, newsql.lastIndexOf("WHERE") + 6);

                        var sqlwhere = sqlone.substring(sqlone.lastIndexOf("WHERE") + 6,sqlone.lastIndexOf("AND"));

                        sql_arr.push(sqlwhere)
                        number++

                        if(number == colrowidnumber ){


                            var comsql = ''
                            for (i = 0; i < sql_arr.length; i++) {
                                comsql += "(" + sql_arr[i] + ") OR "

                            }
                            comsql ="("+ comsql.substr(0, comsql.length - 3)+") and"

                            if (judgeIsAnyNullStr(ID)) {
                                sqlthree = "select RS_A01.ID ID, A0101, (CASE WHEN A0104 = 1 THEN '男'else'女'end) A0104, age, a0140, (SELECT NAME FROM DIC_RS_GB3304 WHERE CODE = A0117) A0117, A0192, (SELECT NAME FROM DIC_rs_Zb09 where code = A0172) A0172 " + sqlwhereone + comsql + " (RS_A01.NID like '" + place_code + "%') " +  "order by rs_a01.aorder "
                            } else {
                                sqlthree = "select RS_A01.ID ID, A0101, (CASE WHEN A0104 = 1 THEN '男'else'女'end) A0104, age, a0140, (SELECT NAME FROM DIC_RS_GB3304 WHERE CODE = A0117) A0117, A0192, (SELECT NAME FROM DIC_rs_Zb09 where code = A0172) A0172 " + sqlwhereone + comsql + " (RS_A01.NID like '" + ID + "%') " + "order by rs_a01.aorder "

                            }


                            var item = {
                                sql: sqlthree,
                                name: name
                            }
                            comOpenWin('dwpeolist_win', '../dwlist/', item, 2);

                        }

                    })
                }
            }

        }
    }



    function cleanarr() {
        peosqllist = []
        sqlthree = null
    }



    function converFcrySql(colsid, rowsid) {
        var sql = "SELECT * FROM GWY_RPT_LD_NODESQL WHERE  ROWSID='" + rowsid + "' AND COLSID='" + colsid + "' AND RPTABLEID='JT2017001';"
        return sql
    }

</script>
</html>